##############################
#   显示文字   
#   by Jerry Yang      
#   UUZ0226            
#############################
import pygame.font

class GameText():
    """显示文字的类"""
    def __init__(self, ai_settings, screen,text_con,text_size):
        """初始化属性"""
        self.text_con = text_con
        self.screen = screen
        self.screen_rect = screen.get_rect()
        self.ai_settings = ai_settings
        # 显示信息时使用的字体设置
        self.size = text_size
        self.text_color = ai_settings.text_color
        self.font = pygame.font.SysFont('nlxjtregular', self.size)
        # 准备初始图像
        self.prep_welcome()
        
    def prep_welcome(self):
        """将文字转换为一幅渲染的图像"""
        self.welcome_image = self.font.render(self.text_con, True, self.text_color,
            self.ai_settings.bg_color)
        # 将欢迎放在屏幕中间
        self.welcome_rect = self.welcome_image.get_rect()
        self.welcome_rect.centerx = self.screen_rect.centerx
        self.welcome_rect.centery = self.screen_rect.centery-50

    def show_welcome(self):
        """在屏幕上显示"""
        self.screen.blit(self.welcome_image, self.welcome_rect)